import 'dart:io';
import 'package:http/http.dart' as http;

// 文件上传
Future<void> uploadFile() async {
  final file = File('path/to/local/file.txt');
  final request = http.MultipartRequest('POST', Uri.parse('http://server_ip:8080/upload'));
  request.files.add(await http.MultipartFile.fromPath('file', file.path));

  final response = await request.send();
  if (response.statusCode == 200) {
    print('File uploaded successfully');
  } else {
    print('File upload failed');
  }
}

// 文件下载
Future<void> downloadFile() async {
  final response = await http.get(Uri.parse('http://server_ip:8080/download'));
  if (response.statusCode == 200) {
    final file = File('path/to/save/downloaded_file.txt');
    await file.writeAsBytes(response.bodyBytes);
    print('File downloaded successfully');
  } else {
    print('File download failed');
  }
}